package com.qys.livesMall.system.controller.app;

import com.qys.livesMall.system.model.entity.Country;
import com.qys.livesMall.system.service.CountryService;
import com.qys.livesMall.common.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author
 * @since 2023-08-28
 */
@RestController
@RequestMapping("/app/country")
@Tag(name = "国家区域前缀", description = "国家区域前缀")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class APPCountryController {

    private final CountryService countryService;

    @GetMapping("/list")
    @Operation(summary = "国家区域前缀集合")
    public R<List<Country>> lit(){
        return R.ok(countryService.list());
    }

    /**
     * 获取国家
     * @param id
     * @return
     */
    @GetMapping("/byId/{id}")
    @Operation(summary = "国家区域前缀集合")
    public R<Country> getById(@PathVariable("id") Long id){
        return R.ok(countryService.getById(id));
    }
}
